home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / Asymptote Demo / Examples / Demos / 13) Graphics / demo13
Encoding:
Text File  |  1994-05-07  |  6.2 KB  |  391 lines  |  [TEXT/DWat]

  1. % Demo some of the various graphics features of Asymptote
  2.  
  3. npts 0        % To clear out the labels
  4. graphframe 0.5 8 1.25 10
  5. scale 2
  6. drawtitle Examples of Asymptote Graphics
  7. scale 1
  8.  
  9. graphframe 0.5 8 1 9
  10. graphpane_setup 3 3 0.25 0.5
  11. graphlimits 0 11 0 11
  12.  
  13. % Point symbols
  14. graphpane 1 3
  15. fullscreen yes
  16. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  17. drawtitle POINT SYMBOLS
  18. npts 10
  19. xrange 1 10
  20. rpn <y 1 >y
  21. rpn <x 10 * open + >p
  22. rpn <y 1 + >y
  23. plotpoints
  24. rpn <x 10 * cross + >p
  25. rpn <y 1 + >y
  26. pencolor blue
  27. plotpoints
  28. rpn <x 10 * star + >p
  29. rpn <y 1 + >y
  30. pencolor red
  31. plotpoints
  32. rpn <x 10 * filled + >p
  33. rpn <y 1 + >y
  34. pencolor green
  35. plotpoints
  36. rpn <x 10 * open + chs >p
  37. rpn <y 1 + >y
  38. penpattern gray
  39. pensize 1
  40. pencolor magenta
  41. plotpoints
  42. rpn <x 10 * cross + chs >p
  43. rpn <y 1 + >y
  44. pencolor blue
  45. penpattern black
  46. pensize 0.5
  47. plotpoints
  48. rpn <x 10 * star + chs >p
  49. rpn <y 1 + >y
  50. pensize 0.25
  51. pencolor yellow
  52. plotpoints
  53. fillpattern none
  54. pencolor green
  55. plotpoints
  56. rpn <x 10 * filled + chs >p
  57. rpn <y 1 + >y
  58. fillpattern gray
  59. pensize 0.5
  60. plotpoints
  61. fillpattern none
  62. pencolor red
  63. plotpoints
  64.  
  65. pensize 0.25
  66. penpattern black
  67. fillpattern black
  68. pencolor black
  69.  
  70. % Error bars
  71. graphpane 1 2
  72. showgraph
  73. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  74. drawtitle ERROR BARS && LIMITS
  75. xrange 1 10
  76. rpn ran 1 + 4 * 2 + >y
  77. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  78. ploterrors left
  79. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  80. ploterrors right
  81. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  82. ploterrors top
  83. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  84. ploterrors bottom
  85. pointsymbol 4 filled
  86. pointsize 4
  87. pencolor red
  88. plotpoints
  89.  
  90. % Set up to errors with no cross bars or arrows, just lines
  91. pencolor blue
  92. scale 0
  93. rpn ran 1 + 4 * 2 + >y
  94. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  95. ploterrors left
  96. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  97. ploterrors right
  98. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  99. ploterrors top
  100. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  101. ploterrors bottom
  102. pointsymbol 4 filled
  103. pointsize 4
  104. pencolor red
  105. scale 1
  106. plotpoints
  107.  
  108. pencolor black
  109. showgraph
  110.  
  111. % Pen dashes & patterns
  112. graphpane 1 1
  113. showgraph
  114. drawtitle PEN DASHES && PATTERNS
  115. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  116. moveto 1 1
  117. pensize 1
  118. penpattern black
  119. pendash long short
  120. pencolor y 10 * 0 100 y 10 * -
  121. drawto 10 y
  122.  
  123. moveto 1 y 1 +
  124. pensize 1
  125. penpattern gray
  126. pendash long short short short
  127. pencolor y 10 * 0 100 y 10 * -
  128. drawto 10 y
  129.  
  130. moveto 1 y 1 +
  131. pensize 0.25
  132. penpattern black
  133. pendash dot
  134. pencolor y 10 * 0 100 y 10 * -
  135. drawto 10 y
  136.  
  137. moveto 1 y 1 +
  138. pensize 1
  139. penpattern lightgray
  140. pendash long short long short
  141. pencolor y 10 * 0 100 y 10 * -
  142. drawto 10 y
  143.  
  144. moveto 1 y 1 +
  145. pensize 1
  146. penpattern black
  147. pendash dot dot long dot dot dot
  148. pencolor y 10 * 0 100 y 10 * -
  149. drawto 10 y
  150.  
  151. moveto 1 y 1 +
  152. pensize 1
  153. penpattern darkgray
  154. pendash short dot dot dot
  155. pencolor y 10 * 0 100 y 10 * -
  156. drawto 10 y
  157.  
  158. moveto 1 y 1 +
  159. pensize 0.5
  160. penpattern black
  161. pendash long dot dot dot dot dot
  162. pencolor y 10 * 0 100 y 10 * -
  163. drawto 10 y
  164.  
  165. moveto 1 y 1 +
  166. pensize 1
  167. penpattern black
  168. pendash dot dot dot short short short
  169. pencolor y 10 * 0 100 y 10 * -
  170. drawto 10 y
  171.  
  172. moveto 1 y 1 +
  173. pensize 3
  174. penpattern black
  175. pendash long short
  176. pencolor y 10 * 0 100 y 10 * -
  177. drawto 10 y
  178.  
  179. moveto 1 y 1 +
  180. pensize 4
  181. penpattern diagonal
  182. pendash solid
  183. pencolor y 10 * 0 100 y 10 * -
  184. drawto 10 y
  185.  
  186. pensize 0.25
  187. pendash solid
  188. penpattern black
  189. pencolor black
  190.  
  191. % Fonts rotated text
  192. graphpane 2 3
  193. showgraph
  194. drawtitle LABELS && TEXT
  195. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  196.  
  197. moveto 2 2
  198. fontname times
  199. fontsize 24
  200. drawlabel center Label
  201.  
  202. moveto 5 5
  203. fontname Times
  204. fontsize 12
  205. rotation 45
  206. pencolor 90 78 34
  207. drawlabel center y = 34 x\\u2 + 45.93
  208.  
  209. moveto 7 2
  210. fontname Helvetica
  211. fontsize 24
  212. rotation 90
  213. pencolor red
  214. drawlabel center \st\\dH\d2O 
  215.  
  216. moveto 8 8
  217. fontname Palatino
  218. fontsize 24
  219. rotation 0
  220. pencolor blue
  221. drawlabel center y = e\\u-\ii\spx\sn
  222.  
  223. moveto 1 10
  224. fontname Courier
  225. fontsize 8
  226. rotation 0
  227. pencolor 50 50 50
  228. drawlabel centerright Date:\# Time:\@
  229.  
  230. moveto 1 5
  231. fontname Times
  232. fontsize 12
  233. rotation -45
  234. pencolor black
  235. drawlabel center \\iitalic
  236.  
  237. moveto 10 3
  238. fontname Times
  239. fontsize 12
  240. rotation -45
  241. drawlabel centerleft \\sT/E - n/i
  242.  
  243. moveto 3 7
  244. fontname Helvetica
  245. fontsize 12
  246. rotation 270
  247. drawlabel center TESTING
  248.  
  249. rotation 0
  250. fontname Helvetica
  251. fontsize
  252.  
  253.  
  254. % Plot histogram
  255. graphpane 2 2
  256. showgraph
  257. drawtitle PLOT HISTOGRAMS
  258. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  259.  
  260. npts 36
  261. xrange -10 10
  262. rpn deg <x dup * -3 / e^x >y
  263. graphlimits
  264. fillpattern diagonal
  265. plothistogram 0
  266.  
  267. % Plot polygon
  268. graphpane 2 1
  269. showgraph
  270. drawtitle PLOT POLYGONS
  271. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  272. npts 7
  273.  
  274. rpn ran >x ran >y
  275. sort
  276. graphlimits
  277. fillpattern darkgray
  278. penpattern gray
  279. pendash long
  280. pencolor blue
  281. plotpolygon closed
  282.  
  283. pencolor black
  284. penpattern black
  285. fillpattern black
  286. pendash solid
  287.  
  288. % Plot points & line
  289. graphpane 3 3
  290. showgraph
  291. drawtitle PLOT LINES && POINTS
  292. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  293. pointsize 4
  294.  
  295. npts 5
  296. rpn ran >x ran >y
  297. sort
  298. spline
  299. graphlimits
  300. pendash solid
  301. pensize 0.5
  302. pencolor 50 100 50
  303. plotline
  304. pensize 0.25
  305. pointsymbol 4 filled
  306. pencolor red
  307. plotpoints
  308.  
  309. npts 5
  310. rpn ran >x ran >y
  311. sort
  312. spline 
  313. graphlimits
  314. pendash short dot dot dot
  315. pensize 0.5
  316. pencolor 100 50 50
  317. plotline
  318. pensize 0.25
  319. pencolor cyan
  320. plotpoints
  321.  
  322. npts 5
  323. rpn ran >x ran >y
  324. sort
  325. spline
  326. graphlimits
  327. pendash dot
  328. pensize 0.5
  329. pencolor 50 50 100
  330. plotline
  331. pensize 0.25
  332. pencolor magenta
  333. plotpoints
  334.  
  335. pensize 0.15
  336. pendash solid
  337. pencolor black
  338.  
  339. % Plot arrows
  340. graphpane 3 2
  341. showgraph
  342. drawtitle PLOT ARROWS
  343. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  344. npts 30
  345.  
  346. xrange 0 360
  347. rpn deg <x dup sin 2 * >x drop cos 2 * >y
  348.  
  349. graphlimits -5 5 -5 5
  350. rpn <y 2 * <x 2 * <y <x roll+2
  351. pencolor blue
  352. plotarrows
  353. pointsymbol 20 filled
  354. pencolor 10 90 10
  355. plotpoints
  356.  
  357. pencolor black
  358.  
  359. % Plot labels
  360. graphpane 3 1
  361. showgraph
  362. drawtitle PLOT LABELS
  363. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  364.  
  365. npts 7
  366. rpn ran >x ran >y
  367. datafile Test Data
  368. datalines 2
  369. readcolumn l 1
  370. closewindow \f
  371. graphlimits -1.5 1.5 -1.5 1.5
  372. pointsymbol 4 filled
  373. pencolor 80 40 80
  374. plotpoints
  375. rpn <x 0.1 + >x
  376. pencolor red
  377. plotlabels centerright
  378. npts 0        % To clear out the labels
  379.  
  380.  
  381. closewindow xrange
  382. closewindow graphpane_setup
  383. closewindow graphpane
  384.  
  385. showpage
  386.  
  387.  
  388.  
  389.  
  390.  
  391.